﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Class
{
    class Program
    {
        static Hashtable ha = new Hashtable();
        static List<Student> slist1 = new List<Student>();
        static void Main(string[] args)
        {
            StudentInfo();
        }
        private static void StudentInfo()
        {
            Console.WriteLine("请选择：1、添加学生信息 2、查询学生信息");
            int k= int.Parse(Console.ReadLine());
            switch (k)
            {
                case 1:
                    AddStudent();
                    break;
                case 2:
                    GetStudent();
                    break;
                default:
                    break;
            }


        }
        private static void AddStudent()
        {
            Console.WriteLine("请输入学生学号：");
            int num = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入学生姓名：");
            int name = int.Parse(Console.ReadLine());
            Console.WriteLine("请输入学生年龄：");
            int age = int.Parse(Console.ReadLine());
            Student s = new Student("001","关羽",21);
            if (ha.Contains(s.Num))
            {
                Console.WriteLine("学号重复，请重新输入！！");
            }
            else
            {
                slist1.Add(s);
                ha.Add(s.Num, s);
                StudentInfo();
            }
            
        }
        private static void GetStudent()
        {
            Console.WriteLine("1、查询学号（按学号排序）；2查询姓名（按姓名排序）；3、查询年龄；4、按学号查询；5、退出");
            int k1 = int.Parse(Console.ReadLine());
            switch (k1)
            {
                case 1:
                    slist1.Sort(new NumSort());
                    foreach (Student item in slist1)
                    {
                        Console.WriteLine(item);
                    }
                    break;
                case 2:
                    slist1.Sort(new NameSort());
                    foreach (Student item in slist1)
                    {
                        Console.WriteLine(item);
                    }
                    break;
                case 3:
                    slist1.Sort(new AgeSort());
                    foreach (Student item in slist1)
                    {
                        Console.WriteLine(item);
                    }
                    break;
                case 4:
                    Console.WriteLine("请输入你要查询的学号：");
                    int a = int.Parse(Console.ReadLine());
                    if (ha.Contains(a))
                    {
                        Console.WriteLine(ha[a]);
                    }
                    else
                    {
                        Console.WriteLine("查无此学生！！");
                    }
                    StudentInfo();
                    break;
                case 5:
                    Console.WriteLine("已退出！");
                    break;

                default:
                    break;
            }

        }
    }
}
